import {ref} from "vue";
import axios from "axios";

 function useURLLoader<T>(url: string){
    const result = ref<T | null>(null)
    const loading = ref(true)
    const error = ref(null)

    axios.get(url).then(e=>{
        console.log(e)
        result.value = e.data
        loading.value = false
    }).catch(e=>{
        error.value = e
    })

    return {
        loading,
        error,
        result
    }
}

export default useURLLoader;
